package io.renren.modules.gis_admin.controller;

import io.renren.common.annotation.LogOperation;
import io.renren.common.utils.Result;
import io.renren.common.validator.ValidatorUtils;
import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.DefaultGroup;
import io.renren.modules.gis_admin.dto.ExecuteConfigDTO;
import io.renren.modules.gis_admin.dto.ExecuteResultDTO;
import io.renren.modules.gis_admin.service.BasinConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.annotation.Resource;
import javax.validation.Valid;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 子流域配置
 *
 * @author Mark iu1340@163.com
 * @since 1.0.0 2023-09-23
 */
@RestController
@Api(tags = "子流域配置")
@RequestMapping("/config")
public class BasinConfigController {

  @Resource
  private BasinConfigService basinConfigService;

  @PostMapping("/execute")
  @ApiOperation("执行")
  @LogOperation("执行")
  public Result<ExecuteResultDTO> execute(@Valid @RequestBody ExecuteConfigDTO executeConfigDTO) {
    ValidatorUtils.validateEntity(executeConfigDTO, AddGroup.class, DefaultGroup.class);
    assert executeConfigDTO != null;
    assert executeConfigDTO.getSourceId() != null;
    return new Result<ExecuteResultDTO>().ok(basinConfigService.execute(executeConfigDTO));
  }
}